<?php

/**
 * winbinder 패키지 
 * 
 * 
 * @package php.ui.winbinder
 */


/**
 * WBHyperLink 
 *
 * @package php.ui.winbinder
 */
class WBHyperLink extends WBControl { 
	public function __construct($options = array()) { 
		$options['class'] = HyperLink;

		parent::__construct($options);
	}

	protected function initCreate() { 
		parent::initCreate();
		
		$param = $this->getOption('param');
		$style = $this->getOption('style');

		if (isset($this->color))		$param |= $this->getOption('color');

		if (isset($this->align))	{
			$style |= wbconstant($this->getOption('align'));
		}
		
		$this->setOption('style', $style);
		$this->setOption('param', $param);
	}

	// 객체 초기화 
	protected function initComponent() { 
		parent::initComponent();	

		if (isset($this->text))			$this->setText($this->getOption('text'));
	}

	/**
	 * click 이벤트 실행 
	 *
	 * @param WBEvent $eo 이벤트 객체 
	 */
	public function onClick($eo) { 
		$url = $this->getOption('url');

		if (!$url) { 
			$text = $this->getText();

			$arr = parse_url($text);

			if ($arr['host']) { 
				$url = $text;
			}
		} 

		WBSystem::exec($url);
	}
}

?>